/*jslint vars: true, forin: true, sloppy: true */
/*global angular: false, ocDialog: false */
ocDialog.directive('ocDraggable', ['ocDraggable', function (ocDraggable) {
	'use strict';
	return {
		restrict: 'A',
		compile: function (tElement, tAttributes) {
			return {
				pre: function (scope, element, attrs) {
					ocDraggable.beDraggable({
						which: element
					});
				}
			};
		}
	};
}]).directive('ocDraggableHandle', ['ocDraggable', function (ocDraggable) {
	'use strict';
	return {
		restrict: 'A',
		link: function (scope, element, attrs) {
			var DI = element.inheritedData('draggableInstance');

			if (angular.isDefined(DI)) {
				DI.handle(element);
			} else {
				throw new Error("No parents can be draggable");
			}
		}
	};
}]);
